//社保信息管理 显示表格及js实体

Ext.define('ProductInfo', {
    extend: 'Ext.data.Model',
    fields: [
        "Id"
		, "AreaCode"   //城市编号
		, "AreaName"   //城市
		, "ProductType"   //社保类型
		, "ProductName"   //社保名称
		, "RatioId"   //比例Id
		, "RatioName"   //比例名称
		, "PayFrequency"   //收费频率
		, "PayMonth"   //缴费月份
		, "AdjustBaseMonth"   //调整基数月份
		, "TransactDate"   //办理日期
		, "SuspendDate"   //停办日期
		, "CollectionWay"   //托收方式
		, "SuspendWay"   //停办方式
	],
    idProperty: "Id"
});

Ext.define('SHApp.CompanyManage.ProductInfo.Grid', {
    extend: 'BLBTSystem.grid',
    alias: 'shapp.companymanage.grid',
    requires: ['SHApp.CompanyManage.ProductInfo.Form',
    'SHApp.System.Maintenance.MaintenComBox',     
    'SHApp.System.AdministrativeArea.AreaCmbTree'
    ],
    txtProductTypeID: 'txtProductType',
    txtProductNameID: 'txtProductName',
    dataModel: "ProductInfo",
    dataUrl: "api/productinfo?format=json",
    initComponent: function () {
        var me = this;
        Ext.apply(this);
        me.btnAddID += me.id;
        me.btnEditID += me.id;
        me.btnDeleteID += me.id;
        me.txtProductTypeID += me.id;
        me.txtProductNameID += me.id;
        this.creatTbar();
        this.creatColumns();
        this.callParent(arguments);
        this.checkBtnPermission(me.pvalue);
    },
    creatColumns: function () {
        var me = this;
        me.columns = [{
            text: "Id",
            flex: 1,
            dataIndex: 'Id',
            sortable: false,
            hidden: true
        }, {
            text: "城市编号",
            width: 100,
            dataIndex: 'AreaCode',
            sortable: true,
            hidden: true
        }, {
            text: "城市",
            width: 100,
            dataIndex: 'AreaName',
            sortable: true
        }, {
            text: "社保类型",
            width: 100,
            dataIndex: 'ProductType',
            sortable: true
        }, {
            text: "社保名称",
            width: 100,
            dataIndex: 'ProductName',
            sortable: true
        }, {
            text: "比例Id",
            width: 100,
            dataIndex: 'RatioId',
            sortable: true,
            hidden: true
        }, {
            text: "比例名称",
            width: 100,
            dataIndex: 'RatioName',
            sortable: true
        }, {
            text: "收费频率",
            width: 100,
            dataIndex: 'PayFrequency',
            sortable: true
        }, {
            text: "缴费月份",
            width: 100,
            dataIndex: 'PayMonth',
            sortable: true
        }, {
            text: "调整基数月份",
            width: 100,
            dataIndex: 'AdjustBaseMonth',
            sortable: true
        }, {
            text: "办理日期",
            width: 100,
            dataIndex: 'TransactDate',
            sortable: true            
        }, {
            text: "停办日期",
            width: 100,
            dataIndex: 'SuspendDate',
            sortable: true            
        }, {
            text: "托收方式",
            width: 100,
            dataIndex: 'CollectionWay',
            sortable: true
        }, {
            text: "停办方式",
            width: 100,
            dataIndex: 'SuspendWay',
            sortable: true
        }
		]
    },
    creatTbar: function () {
        var me = this;
        me.tbar = [{
            xtype: 'areacmbtree',
            fieldLabel: "城市:",
            labelWidth: 60,
            name: 'AreaCode',
            id: me.txtProductTypeID,
            width: 180       
        }, {
            xtype: 'textfield',
            disabled: false,
            fieldLabel: '社保名称:',
            labelWidth: 60,
            name: 'ProductName',
            id: me.txtProductNameID,
            width: 180
        }, ' ', {
            xtype: 'button',
            text: '查询',
            iconCls: 'icon-btn-search',
            handler: function () {
                me.clearFilters();
                var vAreaCode = me.down("#" + me.txtProductTypeID).getValue();
                if (vAreaCode != null && vAreaCode.length > 0) {
                    me.addFilter("AreaCode", vAreaCode);
                }

                var vProductName = me.down("#" + me.txtProductNameID).getValue();
                if (vProductName && vProductName.length > 0) {
                    me.addFilter("ProductName", vProductName);
                }

                me.loadByFilter();
            }
        }, '->', {
            xtype: 'button',
            text: '添加',
            id: me.btnAddID,
            iconCls: 'icon-btn-add',
            handler: function () {
                var win = me.getForm('SHApp.CompanyManage.ProductInfo.Form');
                win.loadRecord(new ProductInfo({ Id: null }));
                win.Show("添加");
            }
        }, ' ', {
            xtype: 'button',
            disabled: true,
            id: me.btnEditID,
            text: '修改',
            iconCls: 'icon-btn-edit',
            handler: function () {
                var rs = me.getSelectionModel().getSelection();
                if (rs) {
                    if (rs.length > 0) {
//                        rs[0].data.TransactDate = rs[0].data.TransactDate;
//                        rs[0].data.SuspendDate = rs[0].data.SuspendDate;
                        me.EditData(me.getForm('SHApp.CompanyManage.ProductInfo.Form'));
                    }
                }
            }
        }, ' ', {
            xtype: 'button',
            disabled: true,
            id: me.btnDeleteID,
            text: '删除',
            iconCls: 'icon-btn-delete',
            handler: function () {
                me.DeleteData();
            }
        }
        ]
    }
})

